package com.itheima.edu.info.manager.day9;

import java.awt.List;
import java.text.Collator;
import java.util.*;
import java.util.stream.Stream;

public class Student2Test {
    public static void main(String[] args) {
        Collator instance = Collator.getInstance(Locale.CHINA);
        TreeMap<Student2, String> treeMap = new TreeMap<>(new Comparator<Student2>() {
            @Override
            public int compare(Student2 o1, Student2 o2) {
                int a=o1.getAge()- o2.getAge();
              a=  a==0?instance.compare(o1.getName(),o2.getName()):a;
              return a;
            }
        });
        Student2 st = new Student2("王五", 8);
        Student2 st1 = new Student2("王六", 882);
        Student2 st2 = new Student2("王七", 858);
        Student2 st3 = new Student2("王八", 880);
        Student2 st4 = new Student2("王9", 81);
        Student2 st5 = new Student2("王99", 81);
        Student2 st6 = new Student2("王99", 81);
        Student2 st7 = new Student2("王98", 81);
        treeMap.put(st, "manb");
        treeMap.put(st1, "manb");
        treeMap.put(st2, "manb");
        treeMap.put(st3, "manb");
        treeMap.put(st4, "manb");
        treeMap.put(st5, "manb");
        treeMap.put(st6, "manb");
        treeMap.put(st7, "manb");


        Set<Student2> student2s = treeMap.keySet();
        for (Student2 student2 : student2s) {
            System.out.println(student2 + "---" + treeMap.get(student2));
        }
        System.out.println("------------");
        Set<Map.Entry<Student2, String>> entries = treeMap.entrySet();
        for (Map.Entry<Student2, String> entry : entries) {
            System.out.println(entry);
        }
        System.out.println("---------------------");
        treeMap.forEach((Student2, String) -> {
            System.out.println(Student2 + String);
        });
        int a = a(1, 2, 3, 4, 5, 6, 7, 8, 9);
        System.out.println(a);
        Stream.of(1,2,3,4,5,6,7,8,9).filter(s->s>3).forEach(s-> System.out.println(s));
        TreeSet<Integer>treeser=new TreeSet<>();
        treeser.add(1);
        treeser.add(2);
        treeser.add(3);
        treeser.add(4);
        System.out.println("---------");
        treeser.stream().forEach(s-> System.out.println(s));
        int []arr={1,2,3,4,5,6};
        System.out.println("-----");
        Arrays.stream(arr).forEach(s-> System.out.println(s));
        System.out.println("--------------");
        treeMap.keySet().stream().filter(s->s.getAge()>81).forEach(s->  System.out.println(s));
    }
    public static int a(int...b){
        int sum=0;
        for (int i : b) {
            sum+=i;
        }
        return sum;
    }
}
